<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>04class样式绑定</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <style>
        *{
        margin: 0;
        padding: 0;
        }
        .basic{
            width: 400px;
            height: 100px;
            border: 1px solid black;
        }
        /* 三种心情 */
           .happy{
				border: 4px solid red;;
				background-color: rgba(255, 255, 0, 0.644);
				background: linear-gradient(30deg,yellow,pink,orange,yellow);
			}
			.sad{
				border: 4px dashed black;
				background-color: gray;
			}
			.normal{
				border: 4px solid deepskyblue;
				background-color: skyblue;
			}
			
			/* 三个样式，随意选择，可以同时存在 */
			.atguigu1{
				background-color: yellowgreen;
			}
			.atguigu2{
				font-size: 30px;
				text-shadow:2px 2px 10px red;
			}
			.atguigu3{
				border-radius: 20px;
			}
    </style>
</head>

<body>
    <div id="demo">
        <div class="basic" :class="str">你好</div>
        <button @click="strear">点击切换心情</button>
        <br>
        <div class="basic" :class="obj">你好</div>
        <button @click="obj.atguigu1 = !obj.atguigu1">应用or取消atguigu1</button>
        <button @click="atguigu2">应用or取消atguigu2</button>
        <button @click="obj.atguigu3 = !obj.atguigu3">应用or取消atguigu3</button>
        <br>
        <div class="basic" :class="arr">你好</div>
        <input type="text" @keyup.enter="add">
    </div>
    <script type="text/javascript">
        Vue.config.productionTip = false
        new Vue({
            el: '#demo',
            data: {
                str:'happy',
                obj:{
                    atguigu1 :true,
                    atguigu2 :true,
                    atguigu3 :true
                },
                arr:[]
            },
            methods:{
                strear(){
                    const moodArr=['happy','sad','normal']
                    const index = Math.floor(Math.random()*3)
                    this.str = moodArr[index]
                },
                atguigu2 (){
                    this.obj.atguigu2 = !this.obj.atguigu2
                },
                add(e){
                   const {value} = e.target
                   this.arr.push(value) 
                }
            }
           
        })
    </script>
</body>
<!-- 第一种引入:class='xxx' -->
<!-- 第二种obj对象 -->
<!-- 第三种对象arr[] -->
</html>